{layout name="layout/sharewifi" /}
<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">{$title}</div>
                </div>
                <div class="widget-body am-fr">
                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <table width="100%" class="am-table am-table-hover tpl-table-black">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>图标</th>
                                <th>名称</th>
                                <th>分类</th>
                                <th>地址</th>
                                <th>联网成功</th>
                                <th>联网失败</th>
                                <th>访问次数</th>
                                <th>排序</th>
								<th>状态</th>
                                <th>时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {if !$list->isEmpty()}
                                {foreach $list as $item}
                                <tr>
                                    <td class="am-text-middle">{$item['shop_id']}</td>
                                   <td class="am-text-middle">
                                        <img src="{$item['qrcode']}" width="50" height="50" alt="图标">
                                    </td>
                                    <td class="am-text-middle">
                                        <p class="item-title">{$item['name']}</p>
                                    </td>
                                    <td class="am-text-middle">{$item['category']['name']|default='--'}</td>
                                    <td class="am-text-middle">{$item['city']}{$item['district']}{$item['detail']}</td>
                                    <td class="am-text-middle">{$item['conn_succ']}</td>
                                    <td class="am-text-middle">{$item['conn_fail']}</td>
                                    <td class="am-text-middle">{$item['visit']}</td>
                                    <td class="am-text-middle">{$item['sort']}</td>
                                    <td class="am-text-middle">
                                        <span class="hema-status am-badge x-cur-p {$item['status']['value'] ? ' am-badge-success' : ' am-badge-warning'}" 
                                        data-id="{$item['shop_id']}" 
                                        data-status="{$item['status']['value']}">
                                        {$item['status']['text']}
                                        </span>
                                    </td>
                                    <td class="am-text-middle">{$item['create_time']}</td>
                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">
                                            <a href="javascript:;" class="hema-edit" 
                                             data-id="{$item['shop_id']}">
                                                <i class="am-icon-pencil"></i> 编辑
                                            </a>
                                            <a href="javascript:;" class="hema-del tpl-table-black-operation-del"
                                               data-id="{$item['shop_id']}">
                                                <i class="am-icon-trash"></i> 删除
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                                {/foreach}
                            {else /}
                                <tr>
                                    <td colspan="12" class="am-text-center">暂无记录</td>
                                </tr>
                            {/if}
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr">{:$list->render()} </div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：{:$list->total()}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="sharewifi/shop/edit" /}
<script>
    $(function () {
        //编辑
        $('.hema-edit').on('click', function () {
            var data = $(this).data();
            $.get("{:url('sharewifi.shop/edit')}?id=" + data.id, function (result) {
				if(result.code == 0){
				    $.show_error(result.msg);
				    return false;
				}
				$.showAction({
                    title: '编辑', 
                    area: '750px', 
                    content: template('tpl-edit', {model:result.data.model,category:result.data.category}), 
                    uCheck: true, 
                    success: function ($content) {
                        $('#my-form').formPost({
                            url: "{:url('sharewifi.shop/edit')}?id=" + data.id
                        });
                    }, 
                    btn2: function ($content) {
                        return true;
                    }
                });
            });
        });
        // 状态
        $('.hema-status').click(function () {
            var data = $(this).data();
			var msg = '确定要'+(parseInt(data.status) === 1 ? '关闭' : '开启')+'该门店？';
            var url = "{:url('sharewifi.shop/status')}";
			$('.hema-status').del('id', url,msg);
        });
        // 删除
        var url = "{:url('sharewifi.shop/delete')}";
        $('.hema-del').del('id', url);
    });
</script>

